Skip to content

Ship the Visual C++ runtime on Windows and require libgomp on Linux - #374

Merged
stevyhacker merged 2 commits into
masterfrom
claude/vc-runtime-libgomp
Oct 26, 2026
Merged

stevyhacker merged 2 commits into
masterfrom
claude/vc-runtime-libgomp

Conversation

@stevyhacker

@stevyhacker stevyhacker commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Upstream llama-server (b11669, every backend, CPU included) needs two system libraries that clean or minimal installs lack. Without them every built-in model fails to start:

  • Linux: libgomp.so.1, the GCC OpenMP runtime, linked by libggml-base.so and the libggml-cpu-*.so variants. Minimal Debian and Ubuntu installs don't have it, and none of our packages declared it.
  • Windows: the Microsoft Visual C++ runtime (msvcp140.dll, vcruntime140.dll, vcruntime140_1.dll). A fresh Windows lacks it, and llama-server.exe then exits with 0xC0000135 without printing anything, so LokalBot only said "llama-server exited during startup". LokalBot's own exe links the C runtime statically and doesn't need it.

Found while testing PR 354 on vast.ai containers and a Google Cloud Windows Server 2022 VM.

What changes

Linux packages declare libgomp. deb libgomp1, rpm libgomp.so.1()(64bit), Arch libgomp (in core since Arch split gcc-libs; it ships /usr/lib/libgomp.so.1). The AUR PKGBUILD and .SRCINFO get the same dependency, so the two dependency lists stay identical. The release workflow's install check now also fails if libgomp.so.1 is missing. The README lists it for .tar.gz installs.

The Windows archive and installer carry the Visual C++ runtime.

  • package.sh copies the three DLLs, unmodified, from the build machine's newest Visual Studio (found with vswhere, using its default redistributable version) into vc-runtime\. VC_REDIST_DIR overrides the source folder.
  • The installer installs that folder and removes it on uninstall.
  • The runtime copies the DLLs beside each llama-server.exe before starting it. A copy that differs from the bundled one is replaced (one a running server holds is replaced at a later start).
  • The updater adds vc-runtime\ to installations that predate it.

Missing libraries are named.

  • Setup now runs llama-server --version once before recording a runtime. A runtime that can't load is never installed, so setup no longer reports success with an empty version and no probed flags (what master does).
  • When a start fails, LokalBot says what to install:
    • Linux: the library the loader names, with package names for libgomp and the Vulkan loader.
    • Windows, exit code 0xC0000135 (-1073741515): the Visual C++ Redistributable, with Microsoft's permalink https://aka.ms/vc14/vc_redist.x64.exe. If the runtime DLLs are all present, the message points at the runtime folder instead.
  • GPU probes use the same mapping.

Why app-local DLLs, and not vc_redist.x64.exe from the installer

  • No admin needed. The installer is per-user without admin rights (PrivilegesRequired=lowest), and LokalBot updates itself in place. vc_redist.x64.exe /install needs elevation, which would add a UAC prompt to a silent install, and the portable zip and in-place updates would never run it.
  • Supported by Microsoft. Microsoft supports local deployment of these DLLs: copy them into the application's folder. Deployment in Microsoft C++ and Redistribute Visual C++ files recommend the central redistributable instead, because an app-local copy only gets updates when the app ships them. Each LokalBot release ships the build machine's current DLLs, and the runtime refreshes the copies beside llama-server.exe when they differ, as Microsoft asks of local deployment.
  • Newer than an outdated system copy. Windows loads DLLs from the executable's folder before System32, so an old system-wide runtime (older than the toolset llama.cpp was built with) can't break llama-server either.
  • Kept away from LokalBot's own process. The DLLs sit in a subfolder rather than beside lokalbot.exe, so they never replace the system copy for DLLs loaded into LokalBot's own process, such as GPU drivers.
  • Small. The three DLLs are 0.7 MB; vc_redist.x64.exe is about 25 MB.

License check

  • Microsoft's Visual Studio 2022 Distributable Code list (the REDIST.txt that the license's "Distributable Code" section points to) allows copying and distributing "any of the files" under [VisualStudioFolder]\VC\redist with your program, unmodified. Only the debug_nonredist folders are excluded. Microsoft.VC14x.CRT is among the allowed files.
  • Redistribution is limited to licensed Visual Studio users. Visual Studio Community is licensed for developing open-source projects, and LokalBot is GPL-3.0.
  • THIRD_PARTY_NOTICES.md gets a section that says:
    • which files LokalBot ships, and that they are Microsoft's, under the Visual Studio terms rather than the GPL;
    • that anyone who redistributes them must keep them unmodified and bind recipients to terms at least as protective. This mirrors the note in CPython's Windows LICENSE.txt.
  • The DLLs are separate, unmodified files that LokalBot doesn't link, so the GPL doesn't reach them.

Reproduction (before → after)

Linux: ubuntu:24.04 container

A scratch program, not part of this PR, drives RuntimeManager the way the app does:

  1. ensure_runtime with default settings into a fresh library.
  2. Lease the Think server, with stories260K.gguf (ggml-org's 1 MB test model) as its model.

Before: the v0.11.3 .deb and master's runtime code:

$ dpkg -s lokalbot | grep -E ^(Version|Depends)
Version: 0.11.3-1
Depends: libc6 (>= 2.39), libstdc++6, libgcc-s1, libasound2t64 | libasound2, libxcb1, libxkbcommon0, libxkbcommon-x11-0, libvulkan1, libwayland-client0
$ ldconfig -p | grep libgomp
(nothing)
$ runtime_e2e /tmp/library stories260K.gguf   # master: LokalBot runtime setup, then the Think server
setup: ok, backend Some("CPU"), Some("")
server: Local LLM server failed to start: llama-server exited during startup: /tmp/library/runtimes/llama-cpp/b11669-ubuntu-x64/llama-b11669/llama-server: error while loading shared libraries: libgomp.so.1: cannot open shared object file: No such file or directory

Setup "succeeds" with an empty version. Under auto it also downloaded the Vulkan build, failed to probe it and settled on CPU for good.

After, no libgomp1 (a .tar.gz install): this branch's runtime code:

$ runtime_e2e /tmp/library stories260K.gguf
setup: Local LLM server failed to start: llama-server needs libgomp.so.1, which isn't installed. Install the package that provides it (libgomp1 on Debian, Ubuntu and openSUSE; libgomp on Fedora and Arch), then try again.
server: Local LLM server failed to start: llama-server needs libgomp.so.1, which isn't installed. Install the package that provides it (libgomp1 on Debian, Ubuntu and openSUSE; libgomp on Fedora and Arch), then try again.
$ ls /tmp/library/runtimes/llama-cpp
.downloads

After, with this branch's .deb: built by package-linux-distros.sh from the v0.11.3 release binaries, with this branch's runtime code:

$ dpkg -s lokalbot | grep ^Depends
Depends: libc6 (>= 2.39), libstdc++6, libgcc-s1, libgomp1, libasound2t64 | libasound2, libxcb1, libxkbcommon0, libxkbcommon-x11-0, libvulkan1, libwayland-client0
$ ldconfig -p | grep libgomp
	libgomp.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libgomp.so.1
$ runtime_e2e /tmp/library stories260K.gguf
setup: ok, backend Some("CPU"), Some("version: 0.7.0-dev (build 11669, commit 620d2225c)")
server: healthy at http://127.0.0.1:17872/v1

Other Linux checks:

  • The release workflow's package check, run locally:
    • with libgomp.so.1 added, it passes for the new .deb (ubuntu:24.04), .rpm (fedora:41) and Arch package (archlinux:latest);
    • it fails on v0.11.3's .deb with missing libgomp.so.1.
  • scripts/ci/check-aur-package.sh passes. namcap's one new warning, "Dependency included, but may not be needed ('libgomp')", is expected and now listed in the AUR README: the app doesn't link libgomp, the runtime it downloads does.
  • libllama-common.so also links OpenSSL 3 (libssl.so.3, libcrypto.so.3). I left it out of the dependencies because every minimal image I checked already has it: ubuntu:24.04, debian:trixie-slim, fedora:41 and archlinux:latest. Fedora's and Arch's base images also already have libgomp, so only Debian and Ubuntu actually lacked something.

Windows

Clean Windows without the Visual C++ Redistributable: a fresh Google Cloud windows-2022 VM (no GPU), with debug builds of the same scratch program. They link the C runtime statically, so they run there.

> Microsoft Windows Server 2022 Datacenter 10.0.20348
> Visual C++ runtime in System32:
  msvcp140.dll missing
  vcruntime140.dll missing
  vcruntime140_1.dll missing
> VC++ Redistributable registry key: absent

##### master
> runtime_e2e.exe lib-master stories260K.gguf
setup: ok, backend Some("CPU"), Some("")
server: Local LLM server failed to start: llama-server exited during startup
> llama-server.exe --version
exit code -1073741515 (0xC0000135)

##### this branch, no vc-runtime folder beside the exe (a source build)
> runtime_e2e.exe lib-nort stories260K.gguf
setup: Local LLM server failed to start: llama-server needs the Microsoft Visual C++ Redistributable (x64), which isn't installed. Install it from https://aka.ms/vc14/vc_redist.x64.exe, then try again.
server: Local LLM server failed to start: llama-server needs the Microsoft Visual C++ Redistributable (x64), which isn't installed. Install it from https://aka.ms/vc14/vc_redist.x64.exe, then try again.
> runtime folders recorded: 0

##### this branch, vc-runtime folder beside the exe (as packaged)
> runtime_e2e.exe lib-branch stories260K.gguf
setup: ok, backend Some("CPU"), Some("version: 0.7.0-dev (build 11669, commit 620d2225c)")
server: healthy at http://127.0.0.1:17872/v1
> Visual C++ DLLs beside llama-server.exe:
  lib-branch\runtimes\llama-cpp\b11669-win-cpu-x64\msvcp140.dll  14.44.35211.0
  lib-branch\runtimes\llama-cpp\b11669-win-cpu-x64\vcruntime140.dll  14.44.35211.0
  lib-branch\runtimes\llama-cpp\b11669-win-cpu-x64\vcruntime140_1.dll  14.44.35211.0

This PR's CI installer on the same VM. LokalBot-0.11.3-windows-x86_64-setup.exe comes from the "Windows archive" job on windows-2025. I ran the scratch program from the installed folder, so it used the packaged vc-runtime\:

> LokalBot-0.11.3-windows-x86_64-setup.exe /VERYSILENT
exit code 0
> C:\Users\0xmithrandir\AppData\Local\Programs\LokalBot\vc-runtime
  msvcp140.dll  14.51.36247.0  signature Valid (CN=Microsoft Windows Software Compatibility Publisher)
  vcruntime140.dll  14.51.36247.0  signature Valid (CN=Microsoft Windows Software Compatibility Publisher)
  vcruntime140_1.dll  14.51.36247.0  signature Valid (CN=Microsoft Windows Software Compatibility Publisher)
> Visual C++ runtime in System32: missing
> C:\Users\0xmithrandir\AppData\Local\Programs\LokalBot\runtime_e2e.exe lib-installed stories260K.gguf
setup: ok, backend Some("CPU"), Some("version: 0.7.0-dev (build 11669, commit 620d2225c)")
server: healthy at http://127.0.0.1:17872/v1
> Visual C++ DLLs beside llama-server.exe:
  lib-installed\runtimes\llama-cpp\b11669-win-cpu-x64\msvcp140.dll  14.51.36247.0
  lib-installed\runtimes\llama-cpp\b11669-win-cpu-x64\vcruntime140.dll  14.51.36247.0
  lib-installed\runtimes\llama-cpp\b11669-win-cpu-x64\vcruntime140_1.dll  14.51.36247.0

Refreshing after an update. Running the installed copy against the earlier library replaced the 14.44 DLLs beside its llama-server.exe with the installer's 14.51 ones, and left no .new files behind:

> before: msvcp140.dll 14.44.35211.0, vcruntime140.dll 14.44.35211.0, vcruntime140_1.dll 14.44.35211.0
setup: ok, backend Some("CPU"), Some("version: 0.7.0-dev (build 11669, commit 620d2225c)")
server: healthy at http://127.0.0.1:17872/v1
> after:  msvcp140.dll 14.51.36247.0, vcruntime140.dll 14.51.36247.0, vcruntime140_1.dll 14.51.36247.0
> leftovers:

The VM ran for about 20 minutes and has been deleted, along with its disk.

Windows 11 PC with VC++ 14.51 in System32: this branch's runtime code, with vc-runtime\ taken from Build Tools 2022 (redist 14.44):

> runtime_e2e.exe lib-branch stories260K.gguf   (System32 has VC++ 14.51.36247.0)
setup: ok, backend Some("Vulkan"), Some("version: 0.7.0-dev (build 11669, commit 620d2225c)")
server: healthy at http://127.0.0.1:18372/v1
> Visual C++ DLLs beside llama-server.exe:
lib-branch\runtimes\llama-cpp\b11669-win-vulkan-x64\msvcp140.dll  14.44.35211.0
lib-branch\runtimes\llama-cpp\b11669-win-vulkan-x64\vcruntime140.dll  14.44.35211.0
lib-branch\runtimes\llama-cpp\b11669-win-vulkan-x64\vcruntime140_1.dll  14.44.35211.0

Other Windows checks:

  • The PE imports of the pinned CPU and Vulkan zips need exactly these three DLLs beyond Windows' own. They ship LLVM's libomp.dll themselves, and Vulkan adds vulkan-1.dll.
  • package.sh's Visual Studio lookup, run in Git Bash on the PC, finds BuildTools\VC\Redist\MSVC\14.44.35112\x64\Microsoft.VC143.CRT.

Tests

New tests:

  • the message mapping (Windows 0xC0000135 with and without the runtime, Linux libgomp, unknown and Vulkan libraries, unrelated failures);
  • placing and refreshing the DLLs;
  • setup refusing a runtime whose fake llama-server fails like the real one;
  • a launch of that fake server returning the libgomp message;
  • the updater adding vc-runtime\ to an older installation and refreshing it in a current one.

Ubuntu 24.04: cargo fmt --check, cargo clippy --workspace --all-targets --locked -- -D warnings, and cargo test --workspace --locked all pass.

Windows 11:

  • cargo test -p lokalbot-ai -p lokalbot-update passes (294 and 44 tests).
  • cargo clippy --workspace --all-targets reports only two "variable does not need to be mutable" warnings in plans/claude.rs. They come from master, are Windows-only, and Windows CI doesn't run clippy.

CI: this PR's linux-windows-release.yml run passes.

  • "Windows archive" built the zip and installer with vc-runtime\ from the runner's Visual Studio, and check-windows-installer.ps1 passed, including the new vc-runtime checks.
  • "Linux archive" passed its package check with libgomp.so.1 added.

Upgrades from older versions

  • An in-place update is applied by the running version's updater. The first update from 0.11.3 or earlier therefore doesn't add vc-runtime\; the next one does.
  • Installs from the installer or the zip have it immediately.
  • Until an install has the folder, a machine without the Visual C++ Redistributable gets the new message pointing at it, instead of "llama-server exited during startup".

Upstream llama-server links libgomp.so.1 on Linux and the Visual C++
runtime on Windows. Minimal Linux installs and fresh Windows have
neither, so every built-in model failed to start.

- deb, rpm and Arch packages (and the AUR PKGBUILD) depend on libgomp.
- The Windows archive and installer carry msvcp140, vcruntime140 and
  vcruntime140_1 from the build machine's Visual Studio redist folder
  in vc-runtime/. The runtime copies them beside each llama-server.exe
  (app-local deployment) and refreshes them after an update; the
  updater adds the folder to older installations.
- Setup checks that llama-server loads before recording a runtime, and
  a failed start names what to install: the library the Linux loader
  reports, or the Visual C++ Redistributable for 0xC0000135.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
lokalbot bda0400 Commit Preview URL

Branch Preview URL
Oct 26 2026, 05:03 AM

@stevyhacker
stevyhacker marked this pull request as ready for review October 26, 2026 06:13
@stevyhacker
stevyhacker merged commit 6d82738 into master Oct 26, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant